package com.ruoyi.project.system.uflo.handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.bstek.uflo.env.Context;
import com.bstek.uflo.model.ProcessInstance;
import com.bstek.uflo.model.task.Task;
import com.bstek.uflo.process.listener.TaskListener;
import com.bstek.uflo.process.node.TaskNode;
import com.ruoyi.project.asset.assets.domain.Assets;
import com.ruoyi.project.asset.assets.service.IAssetsService;
import com.ruoyi.project.system.uflo.model.constant.UfloConstant;

/**
 * 资产审核人工任务
 * @author xianz
 *
 */
@Component
public class AssetTaskListener implements TaskListener {

	@Autowired
	IAssetsService assetsService;
	
	@Override
	public boolean beforeTaskCreate(Context context, ProcessInstance processInstance, TaskNode node) {
		return false;
	}

	@Override
	public void onTaskCreate(Context context, Task task) {
		Assets assets = assetsService.getById(task.getBusinessId());
		assets.setTaskId(task.getId());
		//审核中
		assets.setFlowState(UfloConstant.FLOW_STATE_1);
		assetsService.updateById(assets);
	}

	@Override
	public void onTaskComplete(Context context, Task task) {
		
		System.out.println("1");
	}

}
